//
//  BSKStringCheck.m
//  MicroMemory
//
//  Created by rimi on 16/7/12.
//  Copyright © 2016年 BlueSky. All rights reserved.
//

#import "BSKStringCheck.h"

@implementation BSKStringCheck
//邮箱
+ (BOOL) validateEmail:(NSString *)email
{
    NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
    return [emailTest evaluateWithObject:email];
}

//密码
+ (BOOL) validatePassword:(NSString *)passWord
{
    NSString *passWordRegex = @"^[a-zA-Z0-9_]{6,16}+$";
    NSPredicate *passWordPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",passWordRegex];
    return [passWordPredicate evaluateWithObject:passWord];
}
+ (BOOL) validateShortPassword:(NSString *)passWord
{
    NSString *passWordRegex = @"^[a-zA-Z0-9_]{3,12}+$";
    NSPredicate *passWordPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",passWordRegex];
    return [passWordPredicate evaluateWithObject:passWord];
}


//昵称
+ (BOOL) validateNickname:(NSString *)nickname
{
//    NSString *nicknameRegex = @"^[\u4e00-\u9fa5]{1,8}$|^[0-9A-Za-z_]{1,16}$";
//    NSPredicate *passWordPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",nicknameRegex];
	
//    return [passWordPredicate evaluateWithObject:nickname];
	return nickname.length<30;
}

@end
